<template>
    <view class="main">
        <button @click="jumpJd()">跳转京东</button>
    </view>
</template>

<script>
    import {
        JdProductInfo
    } from '@/service/product.js'
    import {
        getTime,
        getStorage
    } from '@/utils/utils.js'
    export default {
        data() {
            return {
                title: 'ProductDetail',
                productId: '',
                shortUrl: ''
            }
        },
        onLoad(param) {
            this.productId = param.productId;
            this.JdProductInfo();
        },
        methods: {
            jumpJd: function() {
                wx.navigateToMiniProgram({
                    appId: 'wx91d27dbf599dff74',
                    path: 'pages/union/proxy/proxy?spreadUrl=' + this.shortUrl,
                    envVersion: 'release',
                    success(res) {
                        // 打开成功
                        console.log("跳转成功");
                    }
                })
            },
            // 商品列表
            async JdProductInfo() {
                let {
                    data
                } = await JdProductInfo({
                    'timestamp': getTime(),
                    'productId': this.productId,
                    'openId': getStorage('openId'),
                });
                this.shortUrl = data.shortURL;
            },
        }
    }
</script>

<style>
</style>
